var role = require("../lib/role");
module.exports = {
	prefix: "/admin_user",
	get: {
		"/list": function() {
			var admin = role.getAdmin(this);
			var query = this.request.query;
			this.body = ResponObj("json", admin.getUserList(query.num, query.page));
		}
	},
	put: {
		"/lock_user/:user_id": function() {
			var admin = role.getAdmin(this);
			var body = this.request.body;
			var user_id = this.params.user_id;
			admin.lockUser(user_id);
			if (body.back_list) {
				this.body = ResponObj("json", admin.getUserList(body.num, body.page));
			} else {
				this.body = ResponObj("string", "锁定用户成功");
			}
		},
		"/unlock_user/:user_id": function() {
			var admin = role.getAdmin(this);
			var body = this.request.body;
			var user_id = this.params.user_id;
			admin.unlockUser(user_id);
			if (body.back_list) {
				this.body = ResponObj("json", admin.getUserList(body.num, body.page));
			} else {
				this.body = ResponObj("string", "解锁用户成功");
			}
		}
	}
}